/**
* 版权声明：厦门睿商网络科技有限公司 版权所有 违者必究
* 日    期：2020-03-23
*/
package com.rzico.article.controller.member;

import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.rzico.annotation.Log;
import com.rzico.article.entity.Article;
import com.rzico.article.service.ArticleService;
import com.rzico.base.BaseController;
import com.rzico.base.CommResult;
import com.rzico.basics.entity.Enterprise;
import com.rzico.basics.entity.Member;
import com.rzico.basics.service.EnterpriseService;
import com.rzico.basics.service.MemberService;
import com.rzico.entity.PageResult;
import com.rzico.entity.Pageable;
import com.rzico.util.StringUtils;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 文章管理控制层
 *
 * @author Rzico Boot
 * @version 1.0
 * @date 2020-03-23
 */
@Api(description = "文章提交接口")
@RestController
@RequestMapping("/member/article")
public class ArticleMemberController extends BaseController {

    @Autowired
    private ArticleService articleService;

    @Autowired
    private EnterpriseService enterpriseService;

    @Autowired
    private MemberService memberService;
    /**
     * 保存文章管理
     *
     * @param article
     * @return
     */
    @ApiOperation("保存文章管理")
    @PostMapping("/save")
    public CommResult<Article> save(@RequestBody Article article, Long type, Long typeId, Long[] tagIds) {
        Member member = memberService.getCurrent();
        if (null == member || StringUtils.isNotBlank(member.getPhone())) {
            return CommResult.error("请先进行手机验证");
        }
        Article result = articleService.save(article,tagIds,member);
        result = articleService.findById(result.getId());
        return CommResult.success(result);
    }


}
